﻿using Sgr.Security.Permissions;

namespace Sgr.Oss
{
    /// <summary>
    /// 对象存储权限定义
    /// </summary>
    public class Permissions : IPermissionProvider
    {
        /// <summary>
        /// 维护对象存储权限
        /// </summary>
        public const string CreateAndUpdateOss = "Sgr.CreateAndUpdateOss";

        /// <summary>
        /// 删除对象存储权限
        /// </summary>
        public const string DeleteOss = "Sgr.DeleteOss";

        /// <summary>
        /// 浏览对象权限
        /// </summary>
        public const string QueryOss = "Sgr.QueryOss";

        /// <summary>
        /// 权限提供者名称
        /// </summary>
        public string ProviderName => "96-对象存储";

        /// <summary>
        /// 获取所有功能权限
        /// </summary>
        public Task<IEnumerable<FunctionPermission>> GetFunctionPermissionsAsync()
        {
            return Task.FromResult(new FunctionPermission[]
            {
                new(CreateAndUpdateOss, "对象存储", "维护对象存储", GrantRoleType.SystemAdmin),
                new(DeleteOss, "对象存储", "删除对象存储", GrantRoleType.SystemAdmin),
                new(QueryOss, "对象存储", "浏览对象", GrantRoleType.SystemAdmin)
            }.AsEnumerable());
        }
    }
}